#include "EmotionLabelItem.h"

EmotionLabelItem::EmotionLabelItem(QWidget *parent)
	: QClickLabel(parent)
{
	connect(this, &QClickLabel::clicked, [this]() {
		emit signalEmotionClicked(m_emotionName);
	});

	initControl();
}

EmotionLabelItem::~EmotionLabelItem()
{
}

void EmotionLabelItem::setEmotionName(const int & name)
{
	m_emotionName = name;

	const QString &imagePath = QString(":/Resources/MainWindow/emotion/%1.png").arg(name);

	/*m_movie = new QMovie(this);
	m_movie->setFileName(imagePath);
	m_movie->setFormat("apng");*/
	m_movie = new QMovie(imagePath, "apng", this);
	m_movie->start();
	m_movie->stop();

	setMovie(m_movie);
}

void EmotionLabelItem::initControl()
{
	setAlignment(Qt::AlignmentFlag::AlignCenter);
	setObjectName("emotionLabelItem");
	setFixedSize(32, 32);
}
